using System.Drawing;
using System.Windows.Forms;

namespace BLGenerator.BusinessLogic.ProjectSettings
{
    public class BooleanProjectSetting : ProjectSetting
    {
        readonly private string _name;

        public BooleanProjectSetting(string name)
        {
            _name = name;
        }

        public override string Name { get { return _name; } }
        public override object DefaultValue { get { return false; } }

        public override Control GetControl()
        {
            CheckBox chkbValue = new CheckBox();
            chkbValue.CheckAlign = ContentAlignment.MiddleCenter;
            chkbValue.Dock = DockStyle.Fill;
            return chkbValue;
        }

        public override object GetSetting(Control control)
        {
            CheckBox chkbValue = control as CheckBox;
            return chkbValue.Checked;
        }

        public override void FillControl(Control control, object value)
        {
            CheckBox chkbValue = control as CheckBox;
            chkbValue.Checked = (bool)value;
        }

        public static object GetValueFromString(string str)
        {
            return bool.Parse(str);
        }
    }
}